package book.test02;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;

public class CountReduce extends Reducer<Text, IntWritable,Text,IntWritable> {
    Text k = new Text();
    IntWritable v = new IntWritable();
    @Override
    protected void reduce(Text key, Iterable<IntWritable> values, Context context) throws IOException, InterruptedException {
        int count = 0;
        //每一组的数据数量就是职位需求量
        for (IntWritable value:values){
            count+=value.get();
        }
        //为了显示好看将”，“改为制表符
        k.set(key.toString().replace(",","\t"));
        v.set(count);
        context.write(k,v);
    }
}
